using UnityEngine;
using System.Collections;

public class AlienScore : MonoBehaviour {
	
	public GUISkin mainSkin;
	private int _score;
	public int score {
		set {
			_score= value;
			bump=50;
			bumpTimer=0;
		}
		get  { return _score;}
	}
	
	public AlienGenome target;
	public float shiftX=0.5f;
	public float shiftY=0.5f;
	
	int bump=0;
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	float bumpTimer=0;
	void Update () {
		bumpTimer+= Time.deltaTime;
		
		/*
		if(bumpTimer > .050) {
			bumpTimer=0;
			bump--;
		}
		*/
	}
	
	void OnGUI() {
		GUIStyle style= new GUIStyle(mainSkin.GetStyle("Score"));
		int deltaSize= (int)((0.5f - bumpTimer) / 0.5f * bump);
		if(deltaSize > 0)
			style.fontSize=36+deltaSize;
		else
			style.fontSize=36;
		
		//if(target != null && target.gameObject.active) 
		{
			Vector3 worldPoint= this.transform.position;
				worldPoint.y+=shiftY;
				worldPoint.x+=shiftX;
			Vector2 screenCoord= Camera.mainCamera.WorldToViewportPoint (worldPoint);
		
			string text= "Score  :  " + score.ToString();
			
			GUI.Label(new Rect(screenCoord.x * (float)Screen.width, (1-screenCoord.y)* (float)Screen.height, 150, 200), text, style);
		}
	}
}
